﻿using Orchard.Messaging.Events;
using Orchard.Messaging.Models;

namespace DreamStore.WebShop.Events
{
    public class EmailMessageHandler : IMessageEventHandler
    {
        public void Sending(MessageContext context)
        {
            if(context.MessagePrepared)
            {
                return;
            }
            switch (context.Type)
            {
                case "SignupConfirmationEmail":
                    context.MailMessage.Subject = context.Properties["Subject"];
                    context.MailMessage.Body = context.Properties["Body"];
                    context.MailMessage.IsBodyHtml = true;
                    context.MessagePrepared = true;
                    break;

                case "OrderConfirmationEmail":
                    context.MailMessage.Subject = context.Properties["Subject"];
                    context.MailMessage.Body = context.Properties["Body"];
                    context.MailMessage.IsBodyHtml = true;
                    context.MessagePrepared = true;
                    break;
            }
        }

        public void Sent(MessageContext context)
        {
            //Not used
        }
    }
}